package com.kaifamiao.provider;

import com.kaifamiao.model.OrderModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.builder.annotation.ProviderMethodResolver;
import org.apache.ibatis.jdbc.SQL;

public class OrderProvider implements ProviderMethodResolver {

    public String allSelectedSeats(@Param("fno")int fno, @Param("rno")String rno) {

        return new SQL(){{
            SELECT("f.fno,r.rno,s.sno");
            FROM("seat s");
            LEFT_OUTER_JOIN("room r on s.rno = r.rno");
            LEFT_OUTER_JOIN("floor f on r.fno = f.fno");

            if(fno != 0){
                WHERE("f.fno = #{fno}");
            }
            if(rno != null){
                WHERE("r.rno = #{rno}");
            }
            WHERE("s.sstate = 1");

        }}.toString();

    }
}
